//
//  LessonShareTableViewCell.m
//  LoveDraw
//
//  Created by 梁晨 on 2017/6/30.
//  Copyright © 2017年 梁晨. All rights reserved.
//

#import "LessonShareTableViewCell.h"
#import "LessonShareCollectionViewCell.h"

@implementation LessonShareTableViewCell


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.imageV = [[UIImageView alloc]init];
        self.ClassL = [[UILabel alloc]init];
        self.detailL = [[UILabel alloc]init];
        self.timeL = [[UILabel alloc]init];
        self.from = [[UILabel alloc]init];
        self.LineV = [[UIView alloc]init];
        
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        
        layout.itemSize = CGSizeMake((KscreenW-88)/3, (KscreenW-88)/3);
        layout.minimumLineSpacing = 10;
        layout.minimumInteritemSpacing = 10;
        layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
        
        self.CollectionV = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        self.CollectionV.delegate = self;
        self.CollectionV.dataSource = self;
        [self.CollectionV registerNib:[UINib nibWithNibName:@"LessonShareCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"LessonShareCollectionViewCell"];
        self.CollectionV.backgroundColor = [UIColor whiteColor];
        
        
        self.ClassL.font = [UIFont fontWithName:@"Thin" size:14];
        self.detailL.font = [UIFont systemFontOfSize:13];
        self.timeL.font = [UIFont systemFontOfSize:12];
        self.from.font = [UIFont systemFontOfSize:12];
        
        
        self.LineV.backgroundColor = UIColors(0xEFEFEF);
        self.ClassL.textColor = PKCOLOR(93, 111, 152);
        self.detailL.textColor = UIColors(0x333333);
        self.timeL.textColor = UIColors(0x555555);
        self.from.textColor = PKCOLOR(118, 135, 170);
        
        
        [self.contentView addSubview:self.imageV];
        [self.contentView addSubview:self.from];
        [self.contentView addSubview:self.ClassL];
        [self.contentView addSubview:self.detailL];
        [self.contentView addSubview:self.CollectionV];
        [self.contentView addSubview:self.timeL];
        [self.contentView addSubview:self.from];
        [self.contentView addSubview:self.LineV];
        
    }
    return self;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 9;
}

// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    LessonShareCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LessonShareCollectionViewCell" forIndexPath:indexPath];
    cell.titleImageV.backgroundColor = [UIColor redColor];
    return cell;
}


/*  self.imageV = [[UIImageView alloc]init];
 self.ClassL = [[UILabel alloc]init];
 self.detailL = [[UILabel alloc]init];
 self.timeL = [[UILabel alloc]init];
 self.from = [[UILabel alloc]init];*/
#pragma mark --- 布局
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(8);
        make.top.equalTo(self.contentView.mas_top).offset(12);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(40);
    }];
    
    [self.ClassL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageV.mas_right).offset(8);
        make.top.equalTo(self.imageV.mas_top);
        make.width.mas_equalTo(150);
    }];
    
    [self.detailL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ClassL.mas_left);
        make.bottom.equalTo(self.imageV.mas_bottom);
    }];
    
    [self.CollectionV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.detailL.mas_bottom).offset(10);
        make.left.equalTo(self.ClassL.mas_left);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-35);
    }];
    
    [self.timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ClassL.mas_left);
        make.top.equalTo(self.CollectionV.mas_bottom).offset(5);
    }];
    
    [self.from mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.CollectionV.mas_right);
        make.centerY.equalTo(self.timeL.mas_centerY);
    }];
    
    [self.LineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom);
        make.left.equalTo(self.contentView.mas_left);
        make.right.equalTo(self.contentView.mas_right);
        make.height.mas_equalTo(1);
    }];
    
}


@end
